using System;
using System.Collections.Generic;
using System.Text;
using Ghasam.Business.DAO;
using Ghasam.Business.Domain.Entity;
using Spring.Transaction.Interceptor;
using NHibernate.Expression;

namespace Ghasam.Business.Services.Impl
{
    public class GoodsService : IGoodsService
    {
        private IGoodsDao goodsDao;

        public IGoodsDao GoodsDao
        {
            get { return goodsDao; }
            set { goodsDao = value; }
        }

        #region IGoodsService Members

        public int CountGoods()
        {
            return goodsDao.CountGoods();
        }

        public IList<Ghasam.Business.Domain.Entity.Goods> GetGoods(int pageSize, int pageNumber)
        {
            return goodsDao.GetGoods(pageSize, pageNumber);
        }

        public Goods GetGoods(int goodsId)
        {
            return goodsDao.FindById(goodsId);
        }

        [Transaction(ReadOnly = false)]
        public void Persist(Goods goods)
        {
            goodsDao.SaveOrUpdate(goods);
        }

        public IList<Goods> SortGoods(string param, bool asc)
        {
            return goodsDao.SortGoods(param, asc);
        }
        #endregion
    }
}
